package com.cn.service.Impl;

import com.cn.dao.BaseDao;
import com.cn.dao.Impl.RoleDaoImpl;
import com.cn.dao.RoleDao;
import com.cn.entity.Role;
import com.cn.service.RoleService;

import java.sql.Connection;
import java.util.Arrays;
import java.util.List;

/**
 * @Author Zhou Tao
 * @Date 2024/5/16 11:04
 */
public class RoleServiceImpl implements RoleService {
    private RoleDao roleDao;

    public RoleServiceImpl(){
        roleDao = new RoleDaoImpl();
    }

    /**
     * 获取角色列表
     * @return
     */
    @Override
    public List<Role> getRoleList() {
        Connection connection = null;
        List<Role> roleList = null;
        try {
            connection = BaseDao.getConnection();
            roleList = roleDao.getRoleList(connection);
        } catch (Exception e) {
            e.printStackTrace();
        }finally{
            BaseDao.closeResource(connection, null, null);
        }
        return roleList;
    }
}
